;; The test fails on Windows. Fix it before removing the following requirement.
; REQUIRES: x86_64-linux
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/cs-interrupt.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t --skip-symbolization --profile-summary-cold-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-UNWINDER
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/cs-interrupt.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t --profile-summary-cold-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0
; RUN: FileCheck %s --input-file %t

; CHECK: [main:1 @ foo]:72:0
; CHECK:  2: 4
; CHECK:  3: 4 bar:4
; CHECK: [main:1 @ foo:3 @ bar]:67:4
; CHECK:  0: 4
; CHECK:  1: 5
; CHECK:  2: 3
; CHECK:  5: 4
; CHECK: [foo]:32:0
; CHECK:  2: 2
; CHECK:  3: 2 bar:2
; CHECK: [bar]:8:2
; CHECK:  0: 1
; CHECK:  1: 1

; CHECK-UNWINDER:      []
; CHECK-UNWINDER-NEXT:   0
; CHECK-UNWINDER-NEXT:   1
; CHECK-UNWINDER-NEXT:   ffffffffffc00001->5c3:1
; CHECK-UNWINDER-NEXT: [bar]
; CHECK-UNWINDER-NEXT:   1
; CHECK-UNWINDER-NEXT:   5b0-5c3:1
; CHECK-UNWINDER-NEXT:   0
; CHECK-UNWINDER-NEXT: [foo]
; CHECK-UNWINDER-NEXT:   2
; CHECK-UNWINDER-NEXT:   5ff-62f:2
; CHECK-UNWINDER-NEXT:   645-645:2
; CHECK-UNWINDER-NEXT:   3
; CHECK-UNWINDER-NEXT:   62f->5b0:2
; CHECK-UNWINDER-NEXT:   637->645:2
; CHECK-UNWINDER-NEXT:   645->5ff:2
; CHECK-UNWINDER-NEXT: [main:1 @ foo]
; CHECK-UNWINDER-NEXT:   3
; CHECK-UNWINDER-NEXT:   5ff-62f:4
; CHECK-UNWINDER-NEXT:   634-637:4
; CHECK-UNWINDER-NEXT:   645-645:4
; CHECK-UNWINDER-NEXT:   3
; CHECK-UNWINDER-NEXT:   62f->5b0:4
; CHECK-UNWINDER-NEXT:   637->645:4
; CHECK-UNWINDER-NEXT:   645->5ff:4
; CHECK-UNWINDER-NEXT: [main:1 @ foo:3 @ bar]
; CHECK-UNWINDER-NEXT:   4
; CHECK-UNWINDER-NEXT:   5b0-5c8:2
; CHECK-UNWINDER-NEXT:   5b0-5d7:2
; CHECK-UNWINDER-NEXT:   5c3-5d7:1
; CHECK-UNWINDER-NEXT:   5e5-5e9:4
; CHECK-UNWINDER-NEXT:   3
; CHECK-UNWINDER-NEXT:   5c8->5dc:2
; CHECK-UNWINDER-NEXT:   5d7->5e5:4
; CHECK-UNWINDER-NEXT:   5e9->634:4

; original code:
; clang -O0 -g test.c -o a.out
#include <stdio.h>

int bar(int x, int y) {
  if (x % 3) {
    return x - y;
  }
  return x + y;
}

void foo() {
  int s, i = 0;
  while (i++ < 4000 * 4000)
    if (i % 91) s = bar(i, s); else s += 30;
  printf("sum is %d\n", s);
}

int main() {
  foo();
  return 0;
}
